package com.example.doctorstation.POJOController;
import com.example.doctorstation.Config.MyResponse;
import com.example.doctorstation.POJOMapper.DepartmentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

@RestController
public class DepartmentController {
    //注入UserMapper 这里DEA可能会提示报错不用理会就行
    @Autowired
    DepartmentMapper departmentMapper;

    @GetMapping("/department")
    public MyResponse getAllDepartments() {
        try {
            return MyResponse.success("你拿到了所有病区数据！", departmentMapper.findAll());
        } catch (Throwable e) {
            e.printStackTrace(); // error connecting SSH server
            return MyResponse.error("没有病区数据");
        }
    }
}
